package cn.yili12.business.dto;


import cn.yili12.business.entity.MessageDb;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * 消息实体类
 */
@Data
@ApiModel
public class MessageDTO {
    @ApiModelProperty("编号")
    private String id;
    @ApiModelProperty("编号")
    private String no;
    @ApiModelProperty("来自用户编号")
    private String fromUser;
    @ApiModelProperty("去往用户编号")
    private String toUser;
    @ApiModelProperty("发送时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date sendTime;
    @ApiModelProperty("读取时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date readTime;
    @ApiModelProperty("状态(是否已读)")
    private Integer status;
    @ApiModelProperty("内容")
    private String data;

    @ApiModelProperty("来自用户姓名")
    private String fromUserName;
    @ApiModelProperty("去往用户姓名")
    private String toUserName;

    public MessageDTO() {
    }

    public MessageDTO(MessageDb messageDb) {
        this.id = String.valueOf(messageDb.getId());
        this.no = messageDb.getNo();
        this.fromUser = messageDb.getFromUser();
        this.toUser = messageDb.getToUser();
        this.sendTime = messageDb.getSendTime();
        this.readTime = messageDb.getReadTime();
        this.status = messageDb.getStatus();
        this.data = messageDb.getData();
    }
}